﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MyDBconnection;

namespace Thesis_2
{
    public partial class frmSalesR : Form
    {

        DatabaseConnection dbconn = new DatabaseConnection();
        public frmSalesR()
        {
            InitializeComponent();
            txtsearch.TextChanged += new EventHandler(txtsearch_TextChanged);
        }

        void txtsearch_TextChanged(object sender, EventArgs e)
        {
            if (txtsearch.Text != "Search Invoice")
            {
                dbconn.dbconnection();
                dbconn.loadData("SELECT * FROM tblsales WHERE InvoiceNo LIKE '%" + txtsearch.Text + "%'");
                dataGridView1.DataSource = dbconn.tbl;
                dbconn.DBClose();
            }
            else
            {
                getsales();
            }
        }

        private void frmSalesR_Load(object sender, EventArgs e)
        {
            getsales();
            dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
        }
        public void getsales()
        {
            dbconn.dbconnection();
            dbconn.loadData("Select * from tblsales");
            dataGridView1.DataSource = dbconn.tbl;
            dbconn.DBClose();

        }
    }
}
